/*
 * Copyright© 2003-2019 浙江汇信科技有限公司, All Rights Reserved. 
 */
package com.icinfo.cloud.provider.punish.config.service.impl;

import com.icinfo.cloud.provider.common.constant.Constant;
import com.icinfo.cloud.provider.punish.config.dto.ConfigDocumentApprovalFlowAutoRequest;
import com.icinfo.cloud.provider.punish.config.mapper.ConfigDocumentApprovalFlowAutoMapper;
import com.icinfo.cloud.provider.punish.config.model.ConfigDocumentApprovalFlowAuto;
import com.icinfo.cloud.provider.punish.config.service.IConfigDocumentApprovalFlowAutoService;
import com.icinfo.cloud.provider.punish.config.vo.ConfigDocumentApprovalFlowAutoVo;
import com.icinfo.framework.core.service.support.MyBatisServiceSupport;
import com.icinfo.framework.mybatis.mapper.entity.Example;
import com.icinfo.framework.tools.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 描述:  config_document_approval_flow_auto 对应的Service接口实现类.<br>
 *
 * @author framework generator
 * @date 2022年12月05日
 */
@Service
public class ConfigDocumentApprovalFlowAutoServiceImpl extends MyBatisServiceSupport implements IConfigDocumentApprovalFlowAutoService {
    /**
     * 日志记录器
     */
    private static final Logger logger = LoggerFactory.getLogger(ConfigDocumentApprovalFlowAutoServiceImpl.class);

    @Autowired
    private ConfigDocumentApprovalFlowAutoMapper configDocumentApprovalFlowAutoMapper;
    /**
     * 文书自动审批配置信息列表
     * @author liyafeng
     * @date 2022/12/6
      * @param request
     * @return {@link List< ConfigDocumentApprovalFlowAutoVo>}
     */
    @Override
    public List<ConfigDocumentApprovalFlowAutoVo> getConfigDocumentApprovalFlowAutoVoList(ConfigDocumentApprovalFlowAutoRequest request) {
        List<ConfigDocumentApprovalFlowAutoVo> configDocumentApprovalFlowAutoVos=new ArrayList<>();
        if(!StringUtils.isBlank(request.getAutoId())){
            Example example=new Example(ConfigDocumentApprovalFlowAuto.class);
            example.createCriteria().andEqualTo("autoId",request.getAutoId()).andEqualTo("isDeleted", Constant.STRING_0);
            example.setOrderByClause("approval_order_num asc");
            List<ConfigDocumentApprovalFlowAuto>  configDocumentApprovalFlowAutos=configDocumentApprovalFlowAutoMapper.selectByExample(example);
            if(!ObjectUtils.isEmpty(configDocumentApprovalFlowAutos)){
                for(ConfigDocumentApprovalFlowAuto configDocumentApprovalFlowAuto:configDocumentApprovalFlowAutos) {
                    ConfigDocumentApprovalFlowAutoVo vo=new ConfigDocumentApprovalFlowAutoVo();
                    BeanUtils.copyProperties(configDocumentApprovalFlowAuto,vo);
                    configDocumentApprovalFlowAutoVos.add(vo);
                }
            }
        }
        return configDocumentApprovalFlowAutoVos;
    }
}